package com.ruoyi.web.controller.aimp;

import com.ruoyi.aimp.domain.Aimp_Warnreceiver;
import com.ruoyi.aimp.service.IAimp_WarnreceiverService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 接收人信息Controller
 *
 * @author fengfeng
 * @date 2022-06-18
 */
@RestController
@RequestMapping("/ruoyi-aimp/warnreceiver")
public class Aimp_WarnreceiverController extends BaseController
{
    @Autowired
    private IAimp_WarnreceiverService aimp_WarnreceiverService;

    /**
     * 查询接收人信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnreceiver:list')")
    @GetMapping("/list")
    public TableDataInfo list(Aimp_Warnreceiver aimp_Warnreceiver)
    {
        startPage();
        List<Aimp_Warnreceiver> list = aimp_WarnreceiverService.selectAimp_WarnreceiverList(aimp_Warnreceiver);
        return getDataTable(list);
    }

    /**
     * 导出接收人信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnreceiver:export')")
    @Log(title = "接收人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Aimp_Warnreceiver aimp_Warnreceiver)
    {
        List<Aimp_Warnreceiver> list = aimp_WarnreceiverService.selectAimp_WarnreceiverList(aimp_Warnreceiver);
        ExcelUtil<Aimp_Warnreceiver> util = new ExcelUtil<Aimp_Warnreceiver>(Aimp_Warnreceiver.class);
        util.exportExcel(response, list, "接收人信息数据");
    }

    /**
     * 获取接收人信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnreceiver:query')")
    @GetMapping(value = "/{warnreceiverId}")
    public AjaxResult getInfo(@PathVariable("warnreceiverId") Long warnreceiverId)
    {
        return AjaxResult.success(aimp_WarnreceiverService.selectAimp_WarnreceiverByWarnreceiverId(warnreceiverId));
    }

    /**
     * 新增接收人信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnreceiver:add')")
    @Log(title = "接收人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Aimp_Warnreceiver aimp_Warnreceiver)
    {
        return toAjax(aimp_WarnreceiverService.insertAimp_Warnreceiver(aimp_Warnreceiver));
    }

    /**
     * 修改接收人信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnreceiver:edit')")
    @Log(title = "接收人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Aimp_Warnreceiver aimp_Warnreceiver)
    {
        return toAjax(aimp_WarnreceiverService.updateAimp_Warnreceiver(aimp_Warnreceiver));
    }

    /**
     * 删除接收人信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnreceiver:remove')")
    @Log(title = "接收人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warnreceiverIds}")
    public AjaxResult remove(@PathVariable Long[] warnreceiverIds)
    {
        return toAjax(aimp_WarnreceiverService.deleteAimp_WarnreceiverByWarnreceiverIds(warnreceiverIds));
    }
}
